//这是安装订单回显
function indentDeatail(indentId){
	$.post(
		"../orders/getAllGoodsByIndentId.do",	
		{indentId:indentId},
		function(data){
			var rootDiv=$("#indentDeatil").find(".modal-body").first();
			rootDiv.empty();
			console.log(data);
			$.each(data,function(i,goods){
				rootDiv.append('<h3>第'+(i+1)+'个窗户</h3>');
				var formDiv=$('<form name="defaultForm_'+(i+1)+'" method="post" class="form-horizontal"></form>');
				formDiv.append(makeTiTou("安装房间:"));
				var bradioFather=makeRadioFather("anzhuangfangjian");
				$.post(
						"../install/getLocation.do",
						function(aaa){
							$.each(aaa,function(ii,install){
								if(install.locationId==goods.locationId){
									//name,value,content,change,checked
									bradioFather.append(makeRadio2("locationId",install.locationId,install.locationContent,"",'checked="checked"'));
								}else {
									bradioFather.append(makeRadio("locationId",install.locationId,install.locationContent,""));
								}
							});
							//labContent,inputName,inputHou,inputValue
							if(typeof(goods.otherRoom)=="undefined"){
								bradioFather.append(makeInput2("其他房间","otherRoom","",""));	
							}else {
								bradioFather.append(makeInput2("其他房间","otherRoom","",goods.otherRoom));
							}
							formDiv.append(bradioFather);

							if(goods.type==0){
								//布艺帘
								//结构
								formDiv.append('<h4 style="color:blue">布艺帘:</h4>');
								//商品图片
								formDiv.append(makeTiTou("商品图片:"));
								var imgArrar=new Array();
								imgArrar[0]=goods.merchantsImg;
								formDiv.append(makeDuoUploadPhoto2(132,0,"duoPhoto",imgArrar));
								formDiv.append(makeTiTou("结构:"));
								var jiegoubradioFather=makeRadioFather("jiegou");
								jiegoubradioFather.append(makeRadio("structure",0,"单布",""));
								jiegoubradioFather.append(makeRadio("structure",1,"单纱",""));
								jiegoubradioFather.append(makeRadio("structure",2,"布纱双层",""));
								formDiv.append(jiegoubradioFather);	
								$.each(formDiv.find('input[name="structure"]'),function(ii,s){
									if($(s).val()==goods.structure){
										$(s).attr({checked:"checked"});
									}
								});
								if(goods.structure==1){
									//单纱
									formDiv.append(makeTiTou("款式:"));
									var kuanshiradioFather=makeRadioFather("kuanshi");
									kuanshiradioFather.append(makeRadio2("style",1,"韩褶款或挂钩款","",'checked="checked"'));
									formDiv.append(kuanshiradioFather);										
								}else{
									//单布,布纱双层
									//里布
									formDiv.append(makeTiTou("里布:"));
									var liburadioFather=makeRadioFather("libu");
									liburadioFather.append(makeRadio("shadingCloth",1,"遮光里布",""));
									liburadioFather.append(makeRadio("shadingCloth",2,"半遮光里布",""));
									liburadioFather.append(makeRadio("shadingCloth",0,"无",""));
									formDiv.append(liburadioFather);	
									$.each(formDiv.find('input[name="shadingCloth"]'),function(ii,s){
										if($(s).val()==goods.shadingCloth){
											
											$(s).attr({checked:"checked"});
										}
									});
								    //款式
									formDiv.append(makeTiTou("款式:"));
									var kuanshiradioFather=makeRadioFather("kuanshi");
									kuanshiradioFather.append(makeRadio("style",0,"打孔款",""));
									kuanshiradioFather.append(makeRadio("style",1,"韩褶款或挂钩款",""));
									kuanshiradioFather.append(makeRadio("style",2,"帘头款",""));
									formDiv.append(kuanshiradioFather);	
									$.each(formDiv.find('input[name="style"]'),function(ii,s){
										if($(s).val()==goods.style){
											$(s).attr({checked:"checked"});
										}
									});	
									if(goods.structure==2){
										//安装情况
										formDiv.append(makeTiTou("安装情况:"));
										var kuanshiradioFather=makeRadioFather("anzhuangqingkuang");
										kuanshiradioFather.append(makeRadio("installCase",1,"布纱相同位置安装","anzhuangqingkuangChange(this)"));
										kuanshiradioFather.append(makeRadio("installCase",0,"布纱分开安装","anzhuangqingkuangChange(this)"));
										formDiv.append(kuanshiradioFather);	
										$.each(formDiv.find('input[name="installCase"]'),function(ii,s){
											if($(s).val()==goods.installCase){
												$(s).attr({checked:"checked"});
											}
										});	
									}
									//判断是布, 还是帘头
									var json=goods.specials;
									for(var ii=0;ii<json.length;ii++){
										var jj=json[ii];
										if(jj.type==2){
											//帘头
											formDiv.append('<h4 style="color:blue">帘头尺寸:</h4>');
											//帘头安装情况
											formDiv.append(makeTiTou("帘头安装情况:"));
											var cradioFather=makeRadioFather("liantouanzhuangqingkuang");
											cradioFather.append(makeRadio("installSite",0,"窗帘盒",""));
											cradioFather.append(makeRadio("installSite",1,"满墙",""));
											cradioFather.append(makeRadio("installSite",2,"不满墙",""));
											formDiv.append(cradioFather);
											$.each(formDiv.find('input[name="installSite"]'),function(ii,s){
												if($(s).val()==jj.installSite){
													$(s).attr({checked:"checked"});
												}
											});	
											if(jj.installSite==2){
												// 布满墙情况图片
												formDiv.append(makeTiTou("不满墙情况:"));
												var imgArrar=new Array();
												imgArrar[0]=jj.imgs;
												formDiv.append(makeDuoUploadPhoto2(132,0,"duoPhoto",imgArrar));
											}
											//帘头宽度
											formDiv.append(makeInput2("帘头宽度","wide","米",jj.wide));					
											//帘头配件
											formDiv.append(makeTiTou("帘头配件:"));
											formDiv.append(makeInput2("配件长度:","saleNumber","米",jj.saleNumber));					
										}else{
											// 布 ,纱 18316391652
											if(jj.type==0){
												formDiv.append('<h4 style="color:blue">布尺寸:</h4>');
											}else if(jj.type==1){
												formDiv.append('<h4 style="color:blue">纱尺寸:</h4>');
											}							
											//窗户打开方式
											formDiv.append(makeTiTou("窗户打开方式:"));
											var cradioFather=makeRadioFather("chuanghudakaifangshi");
											cradioFather.append(makeRadio("window","平开","平开"));
											cradioFather.append(makeRadio("window","内开","内开"));
											cradioFather.append(makeRadio("window","外开","外开"));
											formDiv.append(cradioFather);	
											$.each(formDiv.find('input[name="window"]'),function(ii,s){
												if($(s).val()==jj.window){
													$(s).attr({checked:"checked"});
												}
											});	
											//布安装位置
											formDiv.append(makeTiTou("安装位置:"));
											var bradioFather111=makeRadioFather("buanzhuangweizhi");
											//type //0 帘头 1 纱 2 布  3 配件 	
											$.post(
													"../install/getInstallation.do",
													{type:2},
													function(data){
														$.each(data,function(i,install){
															if(install.boodycount==jj.installSite){
										
																bradioFather111.append(makeRadio2("installSite",install.boodycount,install.boodycount,"",'checked="checked"'));
															}else {
																bradioFather111.append(makeRadio("installSite",install.boodycount,install.boodycount,""));
															}
														});
														formDiv.append(bradioFather111);	
														//布配件
														formDiv.append(makeTiTou("配件:"));
														var baradioFather=makeRadioFather("bupeijian");
														baradioFather.append(makeRadio("accessoriesType","罗马杆","罗马杆"));
														baradioFather.append(makeRadio("accessoriesType","直轨","直轨"));
														baradioFather.append(makeRadio("accessoriesType","弯轨","弯轨"));
														formDiv.append(baradioFather);		
														$.each(formDiv.find('input[name="accessoriesType"]'),function(ii,s){
															if($(s).val()==jj.accessoriesType){
																$(s).attr({checked:"checked"});
															}
														});															
														//装饰头
														formDiv.append(makeTiTou("装饰头:"));
														var zhuangshitouradioFather=makeRadioFather("zhuangshitou");
														zhuangshitouradioFather.append(makeRadio("acc",0,"标准装饰头"));
														zhuangshitouradioFather.append(makeRadio("acc",1,"单侧小装饰头"));
														zhuangshitouradioFather.append(makeRadio("acc",2,"双侧小装饰头"));
														formDiv.append(zhuangshitouradioFather);
														$.each(formDiv.find('input[name="acc"]'),function(ii,s){
															if($(s).val()==jj.acc){
																$(s).attr({checked:"checked"});
															}
														});		
														//安装方式(配件)
														formDiv.append(makeTiTou("安装方式:"));
														var anZhuangaradioFather=makeRadioFather("anzhuangfangshi");
														anZhuangaradioFather.append(makeRadio("pinstallSite",0,"顶装","anzhuangfangshiChange(this)"));
														anZhuangaradioFather.append(makeRadio("pinstallSite",1,"侧装","anzhuangfangshiChange(this)"));	
														formDiv.append(anZhuangaradioFather);														
														$.each(formDiv.find('input[name="pinstallSite"]'),function(ii,s){
															if($(s).val()==jj.pinstallSite){
																$(s).attr({checked:"checked"});
															}
														});															
														//安装配件
														//安装配件
														rootDiv.append(makeTiTou("安装配件:"));
														
														//布宽, 布高, 杆长
														formDiv.append(makeInput2("宽","wide","米",jj.wide));
														formDiv.append(makeInput2("高","high","米",jj.high));
														formDiv.append(makeInput2("杆长","saleNumber","米",jj.saleNumber));														
														//布制作方法
														formDiv.append(makeTiTou("制作方法:"));
														var buZhiaradioFather=makeRadioFather("buzhizuofangfa");
														buZhiaradioFather.append(makeRadio("production",0,"单开"));
														buZhiaradioFather.append(makeRadio("production",1,"双开"));
														buZhiaradioFather.append(makeInput2("其他","productionOther","开",jj.production));	
														formDiv.append(buZhiaradioFather);														
														$.each(formDiv.find('input[name="production"]'),function(ii,s){
															if($(s).val()==jj.production){
																$(s).attr({checked:"checked"});
															}
														});	
														//TODO 布安装位置拍照
														//商品图片
														formDiv.append(makeTiTou("安装位置拍照:"));
														var tupianArray=jj.imgs;
														formDiv.append(makeDuoUploadPhoto2(132,0,"duoPhoto",tupianArray));
														//备注信息
														formDiv.append(makeTiTou("备注信息:"));
														formDiv.append(makeTextArea("remark"));
					
														formDiv.find('textarea[name="remark"]').first().html(jj.remark);
													},
													"json"
											);
																				
											
										}
									}

								}
								
							}else {
								//成品帘
								//成品帘   宽高  安装方式
								formDiv.append('<h4 style="color:blue">成品帘:</h4>');
								formDiv.append(makeInput2("宽","wide","米",goods.wide));
								formDiv.append(makeInput2("高","high","米",goods.high));
								//成品帘安装方式
								formDiv.append(makeTiTou("安装方式:"));
								var anzhuangfangshiradioFather=makeRadioFather("anzhuangfangshi");
								anzhuangfangshiradioFather.append(makeRadio("pinstallSite",0,"顶装",'checked="checked"'));
								anzhuangfangshiradioFather.append(makeRadio("pinstallSite",1,"侧装",'checked="checked"'));
								formDiv.append(anzhuangfangshiradioFather);									
								$.each(formDiv.find('input[name="pinstallSite"]'),function(ii,s){
									if($(s).val()==goods.pinstallSite){
										$(s).attr({checked:"checked"});
									}
								});	
								
							}							
							
							
						},
						"json"
				);
				rootDiv.append(formDiv);
				
			});
			
		},
		"json"
	);
}
//做多图(只做展示用的)
function makeDuoUploadPhoto2(left,top,name,src){
	var rootDiv=$('<div style="position: relative;margin-top: 20px;"></div>');
	for(var i=0;i<src.length;i++){
		rootDiv.append('<img name="upImg" style="width: 140px;height: 178px;position: relative;margin-left: '+left+'px;margin-top:-'+top+'px" src="http://oeilufnx2.bkt.clouddn.com/'+src[i]+'" name="'+name+'" >');
	}
	return rootDiv;
}

